package com.zfy.tingshu;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * @author 86188
 * @version v1.0
 * @project Default (Template) Project
 * @Date 2025/9/3 14:46
 * @company []
 * @description
 */
@SpringBootApplication
public class Main {
    public static void main(String[] args) {
        SpringApplication.run(Main.class,args);
    }
    @Bean
    public ElasticsearchClient elasticsearchClient(){
        //Create the low-level client
        RestClient restClient = RestClient.builder(new HttpHost("192.168.200.130", 9200)).build();

        //Create the transport with a Jackson mapper
        RestClientTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());

        //And create the API client
        ElasticsearchClient client = new ElasticsearchClient(transport);

        //返回对象
        return client;
    }
}